#include <bits/stdc++.h>
using namespace std;
// 求k有几位数
int weishu(int k) {
  int ci = 0;
  while (k > 0) {
    ci++;
    k = k / 10;
  }
  // cout <<ci<<endl;
  return ci;
}

long long baba(int k) {
  int m = weishu(k);
  long long box = 0;
  while (k > 0) {
    int ge = k % 10;
    long long s = 1;
    for (int i = 1; i <= m; i++) {
      s = s * ge;
    }
    box += s;
    k = k / 10;
  }
  // cout <<box<<endl;
  return box;
}

int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int shu;
    cin >> shu;
    if (baba(shu) == shu)
      cout << "T";
    else
      cout << "F";
    cout << endl;
  }

  return 0;
}